package com.demo.jianjunhuang.catimgwebview;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.webkit.WebView;

/**
 * @author jianjunhuang.me@foxmail.com
 *         create on 2017/7/11.
 *         <p>
 *         1. 拦截图片
 *         2. 图片点击
 *         3. 获取图片 URL
 */

public class CatImgWebView extends WebView {

    private CatWebViewClient catWebViewClient;

    public CatImgWebView(Context context) {
        super(context);
    }

    public CatImgWebView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CatImgWebView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public CatImgWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    public CatImgWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
        super(context, attrs, defStyleAttr, privateBrowsing);
    }

//    public void addJavascriptInterface(Object javascriptInterface) {
//        if(catWebViewClient != null && catWebViewClient.canInterceptImg()){
//            addJavascriptInterface(javascriptInterface, "imagelistener");
//        }
//    }
//
//    public void setWebViewClient(CatWebViewClient client) {
//        super.setWebViewClient(client);
//        this.catWebViewClient = client;
//    }
}
